# 4 - 2 - 1 均方误差 (Mean Squared Error, MSE)的实现
import numpy as np

def mse(y, t):
    return 0.5 * np.sum((y - t) ** 2)

if __name__ == '__main__':
    t = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
    y = [0.1, 0.05, 0.6, 0.0, 0.05, 0.1, 0.0, 0.1, 0.0, 0.0]
    print(mse(np.array(y), np.array(t)))

    y = [0.1, 0.05, 0.1, 0.0, 0.05, 0.1, 0.0, 0.6, 0.0, 0.0]
    print(mse(np.array(y), np.array(t)))